<!doctype html>
<html>

	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<title></title>
		<link href="../../plugins/mui/mui.min.css" rel="stylesheet" />
		<link rel="stylesheet" href="../../css/chineseHospital/registration.css" />
		<script src="../../js/statistics.js"></script>
		<style>
			.header a{
				color:#fff;
			}
		</style>
	</head>

	<body>
		<header class="mui-bar mui-bar-nav header">
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
			<h1 class="mui-title">挂号信息</h1>
		</header>
		<div class="body">
			<div class="status">
				
			</div>
			<div class="title">
				<p>
					<span>就诊人信息</span>
				</p>
				<div class="authentication info-list">
					
				</div>
			</div>
			<div class="list">
				<p>
					<span>就诊信息</span>
				</p>
				<div class="info-list">
					
				</div>
				<div class="code">
					<p>
						<span>预约号码：</span>
						<span></span>
						<!--<span class="able">查看预约号</span>-->
					</p>
					<!--<img style="display: none;" src="https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1507720732728&di=9314be90b6e2319f779e4db85be96d6d&imgtype=0&src=http%3A%2F%2Fa.hiphotos.baidu.com%2Fexp%2Fwhcrop%3D160%2C120%2Fsign%3D2c94c593840a19d8cb56d2475c8abfba%2F91ef76c6a7efce1b7d3d54e8ab51f3deb48f65fa.jpg" />-->
				</div>
			</div>
			<!--<div class="explain">-->
				<!--预约取消说明：临诊前一小时不可取消-->
			<!--</div>-->
		</div>
		<script src='../../plugins/jquery/jquery-3.1.0.min.js'></script>
		<script src="../../plugins/mui/mui.min.js"></script>
		<script src="../../js/getApiToken.js"></script>
		<script src='../../plugins/template/template.js'></script>
		<script type="text/javascript" src="../../js/md5.js" ></script>
		<script src='../../plugins/fontset/fontset.js'></script>
		<script type="text/html" id="title">
			{{if data.status == 0}}
			<a class="cancel">取消预约</a>
			{{else}}
			<a class="re-appointment">重新预约</a>
			{{/if}}
		</script>
		<script type="text/html" id="status">
			<ul>
				{{if data.status == 0}}
				<li>
					预约状态：<span class="access">预约成功</span>
				</li>
				{{else}}
				<li>
					预约状态：<span class="fail">预约取消</span>
				</li>
				{{/if}}
				<li>
					预约时间：<span>{{data.create_time}}</span>
				</li>
			</ul>
		</script>
		<script type="text/html" id="body">
			<ul>
				<li>
					<span>就诊人：</span>
					<span>{{data.name}}</span>
				</li>
				<li>
					<span>医疗卡号：</span>
					<span>{{data.cylh}}</span>
				</li>
				<li>
					<span>就诊费用：</span>
					<span>{{data.cost}}</span>
				</li>
			</ul>
		</script>
		<script type="text/html" id="main">
			<ul>
				<li>
					<span>就诊科室：</span>
					<span>{{data.firstoffice}}</span>
				</li>
				<li>
					<span>诊室名称：</span>
					<span>{{data.secondoffice}}</span>
				</li>
				<li>
					<span>医师姓名：</span>
					<span>{{data.doctor}}</span>
				</li>
				<li>
					<span>就诊类型：</span>
					<span>{{data.type}}</span>
				</li>
				<li>
					<span>就诊日期：</span>
					<span>{{data.date}}</span>
				</li>
				<li>
					<span>就诊时段：</span>
					<span>{{data.time}}</span>
				</li>
				<li>
					<span>就诊地点：</span>
					<span>{{data.address}}</span>
				</li>
			</ul>
		</script>
		<script type="text/javascript">
			mui.init();
			
			mui.plusReady(function(){
				var id = plus.webview.currentWebview().appointmentId,
					yyh;
				mui.back = function(){
					var appointment = plus.webview.getWebviewById('appointment.html');
					plus.webview.currentWebview().close();
					mui.fire(appointment,'refresh');
				};
				myAjax('home/Hospital_service/orderDetail','get',{'id':id},function(data){
					console.log(JSON.stringify(data))
					if(data.code == 1){
						if(data.data.cylh == '' || !data.data.cylh){
							data.data.cylh = '暂无'
						}
						initData(data.data);
						$(".code>p").find("span:last-child").text(data.data.cyyh);
						yyh = data.data.cyyh;
					}
				})
				mui(".header").on('tap','.cancel',function(){
					mui.confirm('是否确定取消预约？','',['确定','取消'],function(value){
						if(value.index == 0){
							myAjax('home/Hospital_service/cancel','post',{'id':id,'cyyh':yyh},function(data){
								console.log(JSON.stringify(data));
								if(data.code == 1){
									mui.toast('取消成功！自动回到我的预约');
									var appointment = plus.webview.getWebviewById('appointment.html');
									mui.fire(appointment,'refresh');
									plus.webview.currentWebview().close();
								}else{
									mui.toast('取消失败，请重试！')
								}
							})
//									mui.toast('取消成功！自动回到我的预约');
//									plus.webview.show('appointment.html','fade-in',200,function(){
//										plus.webview.getWebviewById('appointment.html').reload();
//									})
//									plus.webview.currentWebview().close();
						}
					})
				});
				mui(".header").on('tap','.re-appointment',function(){
					var web = plus.webview.getWebviewById('chineseHospital/index.html');
					if(web){
						plus.webview.show(web);
					}else{
						mui.openWindow({
							url:'index.html',
							id:'chineseHospital/index.html'
						})
					}
				})
			});
			$(function(){
//				$(".code span:last-child").on('tap',function(){
//					$(".code>img").slideDown();
//				})
			});
			function initData(data){
				var body = {
					data:data
				};
				var html = template('title',body),
					html2 = template('status',body),
					html3 = template('body',body),
					html4 = template('main',body);
				$(".header").append(html);
				$(".status").html(html2);
				$(".authentication").html(html3);
				$(".list>.info-list").html(html4);
			}
		</script>
	</body>
</html>